<form action="index.php/contacter/insert/" method="post" name="myform"  onSubmit="return check()"  id="myform">
<div id="inline1">
<h2><span>联系人信息</span></h2>
<table>
    <tr><th colspan="5">联系人：</th></tr>
    <tr>
        <td class="name" width="80"><span>*</span>对应客户：</td>
      	<td width="170" colspan="4">
        <input type="text" id="customer_name" name="customer_name" style=" width:427px;" class="text_width" autocomplete="off" value=<?php echo $customer_name;?>></input>
    </tr>
    <tr>
        <td class="name" width="80"><span>*</span>姓名：</td>
        <td width="170"><input type="text" name="name"  value= ></input></td>
        <td>&nbsp;</td>
        <td class="name" width="80">性别：</td>
        <td width="170" class="ie_6">
            <input type="radio" name="sex" id="man" checked="checked" value="1"/>
            <label for="man">男</label>
            <input type="radio" id="woman" name="sex" value="0"/>
            <label for="woman">女</label>
        </td>
    </tr>
    <tr>
        <td class="name" width="80">负责业务：</td>
        <td width="170"><input type="text" name="business" value= ></input></td>
        <td>&nbsp;</td>
        <!-- <td class="name" width="80">分类：</td>
        <td width="170">
            <select name="classify">
	            <option value="3" selected=selected>普通</option>
	            <option value="2" >不重要</option>
	            <option value="4" >重要</option>
	            <option value="5" >特别重要</option>
	            <option value="1" >失效</option>
            </select>
        </td> -->
    </tr>
    <tr><th colspan="5">现任单位：</th></tr>
    <tr>
        <td class="name" width="80" ><span>*</span>称谓：</td>
        <td width="170"><input type="text" name="appellation" value= ></input></td>
        <td>&nbsp;</td>
        <td class="name" width="80" >类型：</td>
        <td width="170"><input type="text" name="type" value=></input></td>
    </tr>
    <tr>
        <td class="name" width="80" ><span>*</span>部门：</td>
        <td width="170"><input type="text" name="department" value= ></input></td>
        <td>&nbsp;</td>
        <td class="name" width="80" ><span>*</span>职务：</td>
        <td width="170"><input type="text" name="post" value= ></input></td>
    </tr>
    <tr><th colspan="5">联系：</th></tr>
    <tr>
        <td class="name" width="80">工作电话：</td>
        <td width="170"><input type="text" name="work_tel" value= ></input></td>
        <td>&nbsp;</td>
        <td class="name" width="80">传真：</td>
        <td width="170"><input type="text" name="fax" value= ></input></td>
    </tr>
    <tr>
        <td class="name" width="80">移动电话：</td>
        <td width="170"><input type="text" name="mobile_phone" value= ></input></td>
        <td>&nbsp;</td>
        <td class="name" width="80">家庭电话：</td>
        <td width="170"><input type="text" name="home_tel" value= ></input></td>
    </tr>
    <tr>
        <td class="name" width="80">邮件地址：</td>
        <td width="170"><input type="text" name="email" value= ></input></td>
        <td>&nbsp;</td>
        <td class="name" width="80">QQ：</td>
        <td width="170"><input type="text" name="qq" value= ></input></td>
    </tr>
    <tr>
        <td class="name" width="80">邮编：</td>
        <td width="170"><input type="text" name="postcode" value= ></input></td>
        <td>&nbsp;</td>
        <td class="name" width="80">家庭地址：</td>
        <td width="170"><input type="text" name="home_address" value= ></input></td>
    </tr>
    <tr><th colspan="5">附加：</th></tr>
    <tr>
        <td class="name" width="80">兴趣：</td>
      	<td width="170" colspan="4">
        <input style=" width:427px;" name="interest" type="text" value=></input>
    </tr>
    <tr>
        <td class="name" width="80">爱好：</td>
      	<td width="170" colspan="4">
        <input style=" width:427px;" name="hobby" type="text" value=></input>
    </tr>
    <tr>
        <td class="gj_name">备注：</td>
        <td colspan="5"><textarea name="remark" ></textarea></td>
    </tr>
    <tr><td colspan="5">&nbsp;</td></tr>
    <tr class="sub">
        <td colspan="5"><input type="submit" value="提交" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="重置" /></td>
    </tr>
</table>
</div>
</form>
<script type="text/javascript">
function check(){
	var error="";
	var customer_name=document.getElementsByName("customer_name")[0].value;
	var name=document.getElementsByName("name")[0].value;
	var appellation=document.getElementsByName("appellation")[0].value;
	var department=document.getElementsByName("department")[0].value;
	var post=document.getElementsByName("post")[0].value;

	if($.trim(customer_name) == ''){
		 error="错误：\x0d";
         error+="请先填写对应客户,在提交\x0d";
         document.myform.customer_name.focus();
    }
	if($.trim(name) == ''){
		if(error==""){
	    	 error="错误：\x0d";
		 }
         error+="请先填写姓名,在提交\x0d";
         if(customer_name == ''){
        	 document.myform.customer_name.focus();
         }else{
        	 document.myform.name.focus();
         }
    }
    if($.trim(appellation) == ''){
    	if(error==""){
	    	 error="错误：\x0d";
		 }
         error+="请先填写称谓,在提交\x0d";
         if(customer_name == '' && name != "" && appellation != ""){
        	 document.myform.customer_name.focus();
         }
         if(customer_name != '' && name == "" && appellation != ""){
        	 document.myform.name.focus();
         }
         if(customer_name != '' && name != "" && appellation == ""){
        	 document.myform.appellation.focus();
         }
	}
    if($.trim(department) == ''){
    	if(error==""){
	    	 error="错误：\x0d";
		 }
       	 error+="请先填写部门,在提交\x0d";
         if(customer_name == '' && name != "" && appellation != "" && department != ""){
             document.myform.customer_name.focus();
         }
         if(customer_name != '' && name == "" && appellation != "" && department != ""){
             document.myform.name.focus();
         }
         if(customer_name != '' && name != "" && appellation == "" && department != ""){
             document.myform.appellation.focus();
         }
         if(customer_name != '' && name != "" && appellation != "" && department == ""){
             document.myform.department.focus();
         }
	}
    if($.trim(post) == ''){
    	if(error==""){
	    	 error="错误：\x0d";
		 }
     	 error+="请先填写职务,在提交\x0d";
      	if(customer_name == '' && name != "" && appellation != "" && department != "" && post != ""){
            document.myform.customer_name.focus();
        }
        if(customer_name != '' && name == "" && appellation != "" && department != "" && post != ""){
            document.myform.name.focus();
        }
        if(customer_name != '' && name != "" && appellation == "" && department != "" && post != ""){
            document.myform.appellation.focus();
        }
        if(customer_name != '' && name != "" && appellation != "" && department == "" && post != ""){
            document.myform.department.focus();
        }
        if(customer_name != '' && name != "" && appellation != "" && department != "" && post == ""){
        	document.myform.post.focus();
            }
	}
    if(error){
    	alert(error);
		return false;
    }else{
        return true;
    }
}
</script>